//
// Created by gastonfeng on 2023/6/15.
//

#ifndef RTE_STM32F1_TOUCH_XPT2046_H
#define RTE_STM32F1_TOUCH_XPT2046_H

#include "nDevice.h"
#include "XPT2046_touch.h"
#include "firmata.pb.h"
using u8 = unsigned char;
using touch_xpt2046_hw = struct
{
    u8 cs;
    u8 mosi;
    u8 miso;
    u8 clk;
    u8 irq;
    u8 busy;
};

class touch_xpt2046 : public nDevice
{
public:
    explicit touch_xpt2046(touch_xpt2046_hw *hw_config, pb_touch_output *output)
    {
        this->hw_config = hw_config;
        this->output = output;
    }

    int init() final;

    int poll() final;

    touch_xpt2046_hw *hw_config;
    XPT2046_touch *touch;
    SPIClass *spi_touch;
    pb_touch_output *output;
};

#endif // RTE_STM32F1_TOUCH_XPT2046_H
